/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			mw_basicslots.h
  \date			Sep 2011
  \author		TNick

  \brief		Contains the definition for basic slots in MainWindow


  Copyright (c) 2011, Nicu Tofan
 All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
	* Redistributions of source code must retain the above copyright
	  notice, this list of conditions and the following disclaimer.
	* Redistributions in binary form must reproduce the above copyright
	  notice, this list of conditions and the following disclaimer in the
	  documentation and/or other materials provided with the distribution.
	* Neither the name of the copyright holder nor the
	  names of its contributors may be used to endorse or promote products
	  derived from this software without specific prior written permission.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 DISCLAIMED. IN NO EVENT SHALL NICU TOFAN BE LIABLE FOR ANY
 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __MAINWINDOW_BASICSLOTS_INC__
#define __MAINWINDOW_BASICSLOTS_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */


namespace Ui {
class MainWindow;
}

#include	<main.h>

#include	<QObject>
#include    <QCloseEvent>


/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

/// groups event handlers that are most likely to be used by any simple GUI application
/**
*	Initialization function binds actions contained in the MainWindow
*	with internal slots. The actions that are targeted include the
*	new document ones (new and open), save document (current, all, current
*	as a different file), print (actual print, set-up and preview), basic
*	editing (undo and redo, cut copy, paste, delete, select all), changes
*	in the layout direction and help (main help, about, about Qt and
*	contextual help). Also, there is a slot that listens to changes in
*	selection state (present or not) and changes the managed GUI elements
*	accordingly.
*/
class	MW_BasicSlots : public QObject		{
	Q_OBJECT

	friend class MainWindow;

	friend class MW_BasicMdi;
	friend class MW_RecentFiles;
	friend class MW_SheetSlots;
	friend class MW_StyleSheets;
	friend class MW_UiTempl;

	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

public:

	MW_BasicSlots		() ;
	~MW_BasicSlots	() ;


protected:

	/// connects the actions with designed slots
	void	initBasicSlots			(Ui::MainWindow * lc_ui);


	/// reimplement the event handler to allow saving changes before
	void    closeEvent              (QCloseEvent *event);

protected slots:

	/// initialises the instance to represent a new document
	void    slot_New            	( void );

	/// allows for browsing and loads the file in the instance
	void    slot_Open            	( void );

	/// high level; saves the document (may call saveAs())
	void    slot_Save            	( void );

	/// iterates in all opened documents and save them as necessary
	void    slot_SaveAll            ( void );

	/// shows a dialog allowing to select where to save the document
	void    slot_SaveAs            	( void );

	/// presents the print dialog; user is allowed to print
	void    slot_Print            	( void );

	/// presents the page setup dialog for active document
	void    slot_PrintStUp          ( void );

	/// preview printed active document
	void    slot_PrintPreview       ( void );

	/// undo last action in active document
	void    slot_Undo            	( void );

	/// redo last action in active document
	void    slot_Redo            	( void );

	/// cut the selection in active document
	void    slot_Cut            	( void );

	/// copy the selection in active document
	void    slot_Copy            	( void );

	/// paste content of the clipboard in active document
	void    slot_Paste            	( void );

	/// delete the selection in active document
	void    slot_Delete            	( void );

	/// select entire content of the active document
	void    slot_SelAll            	( void );

	/// toogle layout direction (left to right or reverse)
	void    slot_LayDir             ( void );

	/// presents a short message describing the application
	void    slot_About            	( void );

	/// provides access to the help system
	void    slot_Help            	( void );

	/// contextual help for GUI
	void    slot_HelpCtx            ( void );

	/// is informed when the selection in one of the documents changes
	void    slot_SelStateChange     ( void );


	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

}; /* class MW_BasicSlots */
/*  CLASS    =============================================================== */
//
//
//
//
#endif // __MAINWINDOW_BASICSLOTS_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
